#include<iostream>
#include<stack>

using namespace std;

class SelfStack{
    private:
        stack<int> topStack;
        stack<int> dataStack;
    public:
        void pop(){
            int data = dataStack.top();
            // 判断是否为最大数
            if ( data == topStack.top() ){
                // 弹出当前最大值
                topStack.pop();
            }
            dataStack.pop();
        }

        void push(int data){
            if ( topStack.empty() ){
                // topStack为空
                topStack.push(data);
            }else if ( data < topStack.top() ){
                topStack.push(data);
            }
            dataStack.push(data);
        }

        int top(){
            return dataStack.top();
        }

	int min(){
		return topStack.top();
	}

};
int main(void){
    SelfStack selfStack;
    selfStack.push(3);
    cout << "dataStackTop: " << selfStack.top() << "  , topStackTop: " << selfStack.min() << endl;

    selfStack.push(4);
    cout << "dataStackTop: " << selfStack.top() << "  , topStackTop: " << selfStack.min() << endl;

    selfStack.push(2);
    cout << "dataStackTop: " << selfStack.top() << "  , topStackTop: " << selfStack.min() << endl;

    selfStack.push(3);
    cout << "dataStackTop: " << selfStack.top() << "  , topStackTop: " << selfStack.min() << endl;

    selfStack.pop();
    cout << "dataStackTop: " << selfStack.top() << "  , topStackTop: " << selfStack.min() << endl;

    selfStack.pop();
    cout << "dataStackTop: " << selfStack.top() << "  , topStackTop: " << selfStack.min() << endl;

    selfStack.pop();
    cout << "dataStackTop: " << selfStack.top() << "  , topStackTop: " << selfStack.min() << endl;

    selfStack.push(0);
    cout << "dataStackTop: " << selfStack.top() << "  , topStackTop: " << selfStack.min() << endl;
	return 0;
}